package src;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class Player {
	
	Image[] playerImages = new Image[5];
	BufferedImage spriteSheet;
	int count = 0;
	
	public Player(String path, int width, int height){
		ResourceLoader rl = new ResourceLoader();
		try {
			spriteSheet = rl.loadImage(path);
		} catch (IOException e) {
			e.printStackTrace();
		}
		for(int i = 0; i < playerImages.length - 1; i++){
			playerImages[i + 1] = rl.getSprite(i * 32, 0, 32, 32, spriteSheet);
		}
	}
	
	public void draw(Graphics g){
		if(count >= 0 && count < 3){
			g.drawImage(playerImages[1], 400, 300, null);
		}else if(count >= 3 && count < 6){
			g.drawImage(playerImages[2], 400, 300, null);
		}else if(count >= 6 && count < 9){
			g.drawImage(playerImages[3], 400, 300, null);
		}else if(count >= 9 && count < 12){
			g.drawImage(playerImages[4], 400, 300, null);
		}else if(count >= 12 && count < 15){
			count = 0;
		}
		count ++;
	}

}
